package com.iotteam.androidbase.moudules.test_sensor;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.MenuItem;

import com.iotteam.androidbase.R;
import com.iotteam.androidbase.base.ToolbarActivity;
import com.iotteam.androidbase.commen.views.TempDashboardView;
import com.iotteam.androidbase.moudules.main.MainPagerAdapter;
import com.iotteam.androidbase.moudules.main.view.CommenInfoFragment;
import com.iotteam.androidbase.moudules.main.view.SensorListFragment;
import com.iotteam.androidbase.moudules.test_sensor.sensor_info_page.DayInfoPageFragment;
import com.iotteam.androidbase.moudules.test_sensor.sensor_info_page.GeneraInfoPageFragment;
import com.iotteam.androidbase.moudules.test_sensor.sensor_info_page.MonthInfoPageFragment;
import com.iotteam.androidbase.moudules.test_sensor.sensor_info_page.SettingPageFragment;

/**
 * Created by vonchenchen on 13/08/2017.
 */

public class TestChartActivity extends ToolbarActivity implements NavigationView.OnNavigationItemSelectedListener{

    private ViewPager mViewPager;
    private TabLayout mTabLayout;
    private MainPagerAdapter mHomePagerAdapter;
    private TempDashboardView mTempDashboardView;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_test_chart;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
        mViewPager = (ViewPager) findViewById(R.id.viewPager);

        mTempDashboardView = (TempDashboardView) findViewById(R.id.view_temp);

        initView();
    }

    private void initView(){
        mHomePagerAdapter = new MainPagerAdapter(getSupportFragmentManager());
        mHomePagerAdapter.addTab(new DayInfoPageFragment(), "数据记录");
        //mHomePagerAdapter.addTab(new MonthInfoPageFragment(), "历史记录");
        //mHomePagerAdapter.addTab(new GeneraInfoPageFragment(), "综合分析");
        mHomePagerAdapter.addTab(new SettingPageFragment(), "设备控制");
        mViewPager.setAdapter(mHomePagerAdapter);
        mTabLayout.setupWithViewPager(mViewPager, false);

        mTempDashboardView.setRealTimeValue(35);
    }

    public static void launch(Context context) {
        context.startActivity(new Intent(context, TestChartActivity.class));
    }

    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        return false;
    }
}
